#ifndef MEDFILTER_BO_H
#define MEDFILTER_BO_H

#include <stdint.h>
#include <stdlib.h>

//#define LEN1 203  //356*0.8/2  
//#define CHANCOUNT   4

#include <math.h>
#include <stdio.h>
#include <string.h>

#ifdef __cplusplus
extern "C" {
#endif

class MedFilterBO_A  //中值滤波，用了一次中值。
{
private:
	const uint32_t m_unLEN1;
	//double x3BO[2 * LEN1 + 1];
	//double px3BO[2 * LEN1 + 1];
	float *x3BO, *px3BO;
	int icount3BO;
public:

	virtual  MedFilterBO_A*clone() const {
		return  new MedFilterBO_A(*this);
	}
	virtual ~MedFilterBO_A()
	{
		if (x3BO) {
			free(x3BO);
		}
		if (px3BO) {
			free(px3BO);
		}
	}

	MedFilterBO_A(uint32_t len = 203)
		: m_unLEN1(len)
	{
		x3BO = (float*)malloc(sizeof(float) * (2 * m_unLEN1 + 1));
		memset(x3BO, 0, sizeof(float) * (2 * m_unLEN1 + 1));
		px3BO = (float*)malloc(sizeof(float) * (2 * m_unLEN1 + 1));
		memset(px3BO, 0, sizeof(float) * (2 * m_unLEN1 + 1));
		icount3BO = 0;
	}
	double MedFilterBO(float x, int chanId);
	void qSortBO(float* x, int low, int high);
	int iBinSearchBO(const float* sSource, int l, int h, double key);
	double Sum(float* pt, int len);
};

#ifdef __cplusplus
}
#endif

#endif	//#ifndef MEDFILTER_BO_H
